#include "game.h"
#include "display.c"
#include "btns.c"
#include "uart.c"
#include "timer.c"

void init_shape()
{
    update_timer_seed();
    game_shape.pos = timer_rand() % 4;
    game_shape.type = timer_rand() % 7;
    game_shape.shape = TETRIS_SHAPES[game_shape.type][game_shape.pos];
    update_timer_seed();
    game_shape.next_pos = timer_rand() % 4;
    game_shape.next_type = timer_rand() % 7;
    game_shape.next_shape = TETRIS_SHAPES[game_shape.next_type][game_shape.next_pos];
}

void main()
{
    unsigned char btn_code;
    uart_init();
    timer0_init();
    display_init();
    // display_speed_selection();

    init_shape();

    display_shape(1, 10, game_shape.shape);
    display_shape(4, 10, game_shape.next_shape);
    while (1)
    {
        btn_code = btn_scan();
        switch (btn_code)
        {
        case BTN_CODE_UP:
            init_shape();
            display_shape(1, 10, game_shape.shape);
            display_shape(4, 10, game_shape.next_shape);
            break;
        default:
            break;
        }
    }
}